package com.itheima;

/**
 * 2025/3/31 19:58
 * 演示二维数组的使用
 */
public class ArrayDemo {
    public static void main(String[] args) {

        //静态初始化
        int[][] arr1 = {
                {1, 2, 3},
                {4, 5, 6},
                {7, 8, 9}
        };
        //动态初始化
        int[][] arr2 = new int[3][5];
        System.out.println(arr1[1][1]);
        //将arr1中的元素7，修改为77
        arr1[2][0] = 77;
        System.out.println(arr1[2][0]);

        //遍历二维数组
        for (int i = 0; i < arr1.length; i++) {
            for (int j = 0; j < arr1[i].length; j++) {
                //print方法不换行
                //\t 代表tab键
                System.out.print(arr1[i][j]+"\t");
            }
            System.out.println();
        }

    }
}
